package com.recipedb.recipedb.repository;

import com.recipedb.recipedb.entity.Ingredient;
import com.recipedb.recipedb.entity.Tag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;

@Repository
public interface IngredientRepository extends JpaRepository<Ingredient, Long> {

    @Query("SELECT i FROM Ingredient i JOIN RecipeIngredient ri ON i.id = ri.ingredientId WHERE ri.recipeId = :recipeId")
    List<Ingredient> findByRecipeId(@Param("recipeId") Long recipeId);

}
